using System;

namespace tvgrabau
{
	public static class Utils
	{
	    /// <summary>
	    /// Creates a progress bar.
	    /// </summary>
		public static string PrintPercent(double percent, int width)
		{
			//string foo = (char)9556 + PadLen((char)9552, (width - 2)) + (char)9559 + "\n";
		
			char barfoo = '=';
			char foobar_start = '[';
			char foobar_end = ']';
			string foo = foobar_start.ToString();
			
			double rate = (double)width / (double)100;
			double count = rate * percent;
			count = Math.Floor(count);
			
			string bar = "";
			int x = 0;
			while (x < count)
			{
				bar += barfoo;
				x++;
			}
			
			string extra = "";
			int b = 0;
			int y = 3 - percent.ToString().Length;
			while (b < y)
			{
				extra += " ";
				b++;
			}
			
			foo += bar.PadRight(width);
			foo += foobar_end.ToString() + " " + percent.ToString() + "%" + extra;
			
			return foo;
		}
	}
}
